package com.CNMedical.web.controller.system;

import java.util.List;
import javax.annotation.Resource;

import com.CNMedical.system.domain.DTO.AppletExamScoreDTO;
import com.CNMedical.system.domain.vo.AppletExamScoreVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.CNMedical.common.annotation.Log;
import com.CNMedical.common.core.controller.BaseController;
import com.CNMedical.common.core.domain.AjaxResult;
import com.CNMedical.common.enums.BusinessType;
import com.CNMedical.system.domain.entity.AppletExamScore;
import com.CNMedical.system.service.IAppletExamScoreService;
import com.CNMedical.common.core.page.TableDataInfo;

/**
 * 考试成绩Controller
 * 
 * @author tang
 * @date 2023-03-28
 */
@RestController
@RequestMapping("/system/score")
public class AppletExamScoreController extends BaseController
{
    @Resource
    private IAppletExamScoreService appletExamScoreService;

    /**
     * 查询考试成绩列表
     */
    @PreAuthorize("@ss.hasPermi('system:score:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletExamScoreDTO appletExamScore)
    {
        startPage();
        List<AppletExamScoreVO> list = appletExamScoreService.selectAppletExamScoreList(appletExamScore);
        return getDataTable(list);
    }

    /**
     * 获取考试成绩详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:score:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletExamScoreService.selectAppletExamScoreById(id));
    }

    /**
     * 新增考试成绩
     */
    @PreAuthorize("@ss.hasPermi('system:score:add')")
    @Log(title = "考试成绩", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletExamScore appletExamScore)
    {
        return toAjax(appletExamScoreService.insertAppletExamScore(appletExamScore));
    }

    /**
     * 修改考试成绩
     */
    @PreAuthorize("@ss.hasPermi('system:score:edit')")
    @Log(title = "考试成绩", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletExamScore appletExamScore)
    {
        return toAjax(appletExamScoreService.updateAppletExamScore(appletExamScore));
    }

    /**
     * 删除考试成绩
     */
    @PreAuthorize("@ss.hasPermi('system:score:remove')")
    @Log(title = "考试成绩", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletExamScoreService.deleteAppletExamScoreByIds(ids));
    }
}
